import subprocess
import signal

with open('./test_text.txt') as f:
    text=f.read()
    str_len=len(text)
    mod=(str_len+1023)/1024
    path='/home/leo/vscode/vpp/extras/libmemif/examples/test_text.txt'
    # print(mod)
    # print("/home/leo/vscode/vpp/extras/libmemif/examples/socket/s %d"%(str_len))
    # print("/home/leo/vscode/vpp/extras/libmemif/examples/socket/c %s %d"%(path,mod))
    ps=subprocess.Popen("/home/leo/vscode/vpp/extras/libmemif/examples/socket/s %d"%(str_len),shell=True,stdout=subprocess.PIPE)
    pc=subprocess.Popen("/home/leo/vscode/vpp/extras/libmemif/examples/socket/c %s %d"%(path,mod),shell=True,stdout=subprocess.PIPE)
    pc.wait()
    # ps.kill()
    ps.wait()

    str_c=pc.stdout.read().decode()
    print(str_c)
    str_s=ps.stdout.read().decode()
    print(str_s)
    # ps.wait()